import requests
import time
import execjs

t = str(int(time.time()*1000))
url = 'https://www.jdl.cn/ecology/getSession?_={}'.format(t)
headers = {
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36"
}
res = requests.get(url,headers=headers)
session = res.json()['obj']
print(session)
ct = execjs.compile(open(r"E:/nodeProject/js/jd_yzm.js",encoding='UTF-8').read()).call('data',session)
print(ct)

url = 'https://jcap.m.jd.com/cgi-bin/api/fp'
data = {
    "si":session,
    "ct":ct,
    "version":2,
    "lang":1,
    "client":""
}
headers = {
    'authority': 'jcap.m.jd.com',
    'method': 'POST',
    'path': '/cgi-bin/api/fp',
    'scheme': 'https',
    'accept': 'application/json, text/plain, */*',
    'accept-encoding': 'gzip, deflate, br',
    'accept-language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7',
    'cache-control': 'no-cache',
    'content-type': 'application/x-www-form-urlencoded;charset=UTF-8',
    'cookie': 'TrackID=1AOoQV0hRXqpw5UZuT1yHAN_zjlg-V9phLoHX6q-_1cd_cf0DPt7sFe8rqCMjaBXUQuIMJAua7OZKP_VTdUDhLNpxXSsGhhWW4QzXGwndQ1I; thor=317DF86A79D04E8215965CA2889DDF81D80BD84BD52113E163E563DD583F746711B8BB41C1E7EF5B61287801D0182A40249ECA97536FF660850EB67EF464936F094983DA656BAF6B1D533760C5AD13F0991892E5CCEFDEBDABF7FA497B52CE744CE7E48915581224CF17BC48C2E19C7AAAF3FEA96359716CBA30221C284F360F; pinId=HmFWFGJN4LdIdSh6p8esqQ; pin=%E5%90%9B%E4%B8%B0%E4%BB%93%E5%BA%93; unick=%E5%90%9B%E4%B8%B0%E4%BB%93%E5%BA%93; ceshi3.com=000; _tp=e10oAB9dBLaSDC0YXNjnjTY0Zu1YFrVkJ0SsFh9xVKP2l8IjeMBOZGQ4B9ljV6kr; logining=1; _pst=%E5%90%9B%E4%B8%B0%E4%BB%93%E5%BA%93',
    'origin': 'https://www.jdl.cn',
    'pragma': 'no-cache',
    'referer': 'https://www.jdl.cn/',
    'sec-fetch-dest': 'empty',
    'sec-fetch-mode': 'cors',
    'sec-fetch-site': 'cross-site',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36',
}
res = requests.post(url,headers=headers,data=data)
print(res.text)